package com.tanhua.server.service;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.server.mapper.UserInfoMapper;
import com.tanhua.server.pojo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @program: mytanhua
 * @author: Leon
 * @date: 2021-01-31 11:12
 **/
@Service
@SuppressWarnings("all")
public class UserInfoService {
    @Autowired
    UserInfoMapper userInfoMapper;

    public UserInfo queryUserInfoByUserId(Long id) {

        QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",id);
        UserInfo userInfo = userInfoMapper.selectOne(queryWrapper);
        return userInfo;
    }


    public List<UserInfo> queryUserInfoList(QueryWrapper queryWrapper) {
        return userInfoMapper.selectList(queryWrapper);
    }

    public boolean updateUserInfoByUserId(UserInfo userInfo) {
        QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userInfo.getUserId());
        return this.userInfoMapper.update(userInfo, queryWrapper) > 0;
    }
}
